/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package toesp.helper;

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;
import javax.swing.JPanel;

/**
 *
 * @author satria.sp
 */
public class tcomponentHelper {
    
    public void setCenterJPanel(JPanel jp){
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final Dimension screenSize = toolkit.getScreenSize();
        final int x = (screenSize.width - jp.getWidth()) / 2;
        final int y = (screenSize.height - jp.getHeight()) / 2;
        jp.setLocation(x, y);  
//        jp.setVisible(true);
    }
    
    public void setCenterJDialog(JDialog jd){
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final Dimension screenSize = toolkit.getScreenSize();
        final int x = (screenSize.width - jd.getWidth()) / 2;
        final int y = (screenSize.height - jd.getHeight()) / 2;
        jd.setLocation(x, y); 
//        jd.setVisible(true);
    }
}
